package com.zhuoyue.web.controller.system;

import java.util.List;

import com.zhuoyue.system.domain.vo.TblGatewayLogVo;
import com.zhuoyue.system.mapper.SysUserMapper;
import com.zhuoyue.system.mapper.TblGatewayLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhuoyue.common.annotation.Log;
import com.zhuoyue.common.core.controller.BaseController;
import com.zhuoyue.common.core.domain.AjaxResult;
import com.zhuoyue.common.enums.BusinessType;
import com.zhuoyue.system.domain.TblGatewayLog;
import com.zhuoyue.system.service.ITblGatewayLogService;
import com.zhuoyue.common.utils.poi.ExcelUtil;
import com.zhuoyue.common.core.page.TableDataInfo;

/**
 * 网关操作日志Controller
 *
 * @author hewenze
 * @date 2020-12-24
 */
@RestController
@RequestMapping("/system/gatewaylog")
public class TblGatewayLogController extends BaseController {
    @Autowired
    private ITblGatewayLogService tblGatewayLogService;

    @Autowired
    private TblGatewayLogMapper tblGatewayLogMapper;

    @Autowired
    private SysUserMapper sysUserMapper;

    /**
     * 查询网关操作日志列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TblGatewayLogVo tblGatewayLog) {

        startPage();
        List<TblGatewayLogVo> list = tblGatewayLogMapper.selectTblGatewayLogVoList(tblGatewayLog);
        return getDataTable(list);
    }

    /**
     * 导出网关操作日志列表
     */
    @Log(title = "网关操作日志", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TblGatewayLogVo tblGatewayLog) {
        List<TblGatewayLogVo> list = tblGatewayLogMapper.selectTblGatewayLogVoList(tblGatewayLog);
        ExcelUtil<TblGatewayLogVo> util = new ExcelUtil<TblGatewayLogVo>(TblGatewayLogVo.class);
        return util.exportExcel(list, "log");
    }

    /**
     * 获取网关操作日志详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(tblGatewayLogService.selectTblGatewayLogById(id));
    }

    /**
     * 新增网关操作日志
     */
    @Log(title = "网关操作日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TblGatewayLog tblGatewayLog) {
        return toAjax(tblGatewayLogService.insertTblGatewayLog(tblGatewayLog));
    }

    /**
     * 修改网关操作日志
     */
    @Log(title = "网关操作日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TblGatewayLog tblGatewayLog) {
        return toAjax(tblGatewayLogService.updateTblGatewayLog(tblGatewayLog));
    }

    /**
     * 删除网关操作日志
     */
    @Log(title = "网关操作日志", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(tblGatewayLogService.deleteTblGatewayLogByIds(ids));
    }
}
